package com.shierke.Ume.ui.activity.me

import android.content.Context
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.TextureView
import android.view.View
import android.widget.TextView
import com.shierke.Ume.R
import com.shierke.Ume.base.BaseActivity
import com.shierke.Ume.util.startActivity
import com.zhy.view.flowlayout.FlowLayout
import com.zhy.view.flowlayout.TagAdapter
import kotlinx.android.synthetic.main.activity_setting_tag.*

/**
 * Create by Ybx
 * on 2020-10-21
 * Desribe:
 */
class SettingTagActivity : BaseActivity() {


    companion object {
        fun startActivity(context: Context) {
            context.startActivity<SettingTagActivity>()
        }
    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_setting_tag)

        setActivityTitleText(getString(R.string.my_setting_tag_activity_title))
        setActivityRightText("OK")


        val value = object : TagAdapter<String>(initData()) {
            override fun getView(parent: FlowLayout?, position: Int, t: String?): View {

                val view = LayoutInflater.from(this@SettingTagActivity)
                    .inflate(R.layout.item_settingg_tag, null, false) as TextView

                view.text = t
                return view
            }

            override fun onSelected(position: Int, view: View?) {
                val textView = view as TextView
                textView.setTextColor(Color.parseColor("#ffffff"))

            }

            override fun unSelected(position: Int, view: View?) {
                val textView = view as TextView
                textView.setTextColor(Color.parseColor("#2C2C2C"))
            }
        }

        flowLayout.adapter = value
    }


    private fun initData(): ArrayList<String> {
        var arr = arrayListOf<String>(
            "Select a suitable topic",
            "suitable topic",
            "legs",
            "suitable topic",
            "legs",
            "Select a suitable topic"
        )
        return arr
    }

}